<template>
  <div class="project-container" v-loding="loading" ref="project-ref">
    <div v-for="item in data" :key="item.id" class="project-content">
      <a
      
        class="flex"
        :href="
          item.url ? item.url : `javascript:alert('该项目无法通过外网访问')`
        "
        :target="item.url ? '_blank' : '_self'"
      >
        <img v-layz="item.thumb" class="thumb" :src="item.thumb" alt="" />
      </a>

      <div class="info">
        <h2 class="item-title">
          <a
            :href="
              item.url ? item.url : `javascript:alert(该项目无法通过外网访问)`
            "
            :target="item.url ? '_blank' : '_self'"
            >项目名称:{{ item.name }}</a
          >
        </h2>
        <!-- <a target="_blank" v-if="item.github"  class="githup"
          >githup</a
        > -->
        <a class="github"
          target="_blank"
          :href="item.github"
          v-if="item.github">githup</a>
        <p v-for="(info, i) in item.description" :key="i">{{ info }}</p>
      </div>
    </div>
  </div>
</template>

<script>
import mainScroll from '@/mixins/mainScroll'
import { mapState } from "vuex";
export default {
  mixins:[mainScroll("project-ref")],
  computed: {
    ...mapState("project", ["data", "loading"]),
  },
  created() {
    this.$store.dispatch("project/fetchProject");
  },
};
</script>

<style scoped lang='less'>
.project-container {
  width: 100%;
  height: 100%;
  padding: 20px;
  overflow: scroll;
  box-sizing: border-box;
  position: relative;
  scroll-behavior:smooth;
  .project-content {
    display: flex;
    padding: 15px;
    box-sizing: border-box;
    border: 1px solid;
    transition: 0.5s;
    margin-bottom: 20px;
    .flex{
      display: flex;
    }
    &:hover {
      box-shadow: -1px 1px 5px #000;
    }
    .thumb {
      width: 150px;
      height: 150px;
      min-height: 150px;
      object-fit: cover;
      border-radius: 5px;
      flex: 0 0 auto;
      align-items: center;
      align-self: center;
      margin-right: 15px;
    }
    .info {
      line-height: 1.7;
      flex: 1 1 auto;
      h2 {
        margin: 0;
      }
      .github {
        font-size: 14px;
        color: #f40;
      }
    }
  }
}
</style>